#region (c) 2014 THN Solutions LLC. - All rights reserved
/*
THN DATA ABSTRACTION LAYER version 1

Copyright (c) 2014, THN Solutions LLC. ( www.ThnSolutions.com )
Author: Nguyễn, M. Hải                 ( www.Minh-Hai.com     )
All rights reserved.

This library is dual-licensed.
  + For commercial software, please obtain a commercial license from THN Solutions LLC.

  + For free software, this library is licensed under GPL version 3. A summary of GPLv3 is
    listed below. You should also find a copy of GPLv3 as file License_GPLv3.txt included
	with the source-code files.

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License version 3 as published by
    the Free Software Foundation  of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
#endregion

#region Using directives
using System;
using Thn.Application;
#endregion

namespace Thn.Data.Persistence
{
    /// <summary>
    /// Base class for command logging used by persistence service
    /// </summary>
    public class PersistentCommand
    {
        #region Time Stamp
        private DateTime mTimeStamp;
        /// <summary>
        /// Gets/Sets the stamp of time when this command was created
        /// </summary>
        public DateTime TimeStamp
        {
            get { return mTimeStamp; }
            set { mTimeStamp = value; }
        }
        #endregion		

        #region Status
        private PersistentCommandStatus mStatus = PersistentCommandStatus.NotProcessed;
        /// <summary>
        /// Gets/Sets Status
        /// </summary>
        [Savable]
        public PersistentCommandStatus Status
        {
            get { return mStatus; }
            set { mStatus = value; }
        }
        #endregion

        #region Error
        private Exception mError;
        /// <summary>
        /// Gets/Sets the error occurred during previous processing
        /// </summary>
        public Exception Error
        {
            get { return mError; }
            set { mError = value; }
        }
        #endregion	

        #region Constructors
        /// <summary>
        /// Default constructor
        /// </summary>
        public PersistentCommand()
        {
            mTimeStamp = DateTime.Now;
        }
        #endregion
    }

    /// <summary>
    /// State of a persistent command
    /// </summary>
    public enum PersistentCommandStatus
    {
        /// <summary>
        /// This command has not been processed before
        /// </summary>
        NotProcessed,

        /// <summary>
        /// This command was deemed as a failure during previous processing
        /// </summary>
        Failed,

        /// <summary>
        /// This command was deemed as a success during previous processing
        /// </summary>
        Succeeded,

        /// <summary>
        /// This command was discarded because it is unneccesary. Other commands have overlappsed this command.
        /// </summary>
        Skipped
    }
}
